package de.uhlesoluschns.opensearch.ui;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.provider.LiveFolders;
import de.uhlesoluschns.opensearch.OpenSearch.Provider;
import de.uhlesoluschns.opensearch.OpenSearch.ProviderLiveFolder;

public class SearchProviderList extends ListActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		final Intent intent = getIntent();
		final String action = intent.getAction();
		
		if(LiveFolders.ACTION_CREATE_LIVE_FOLDER.equals(action)) {
			setResult(RESULT_OK, createLiveFolder());
			finish();
		}
		
	}

	private static Intent createLiveFolder() {
		final Intent intent = new Intent();
		intent.setData(ProviderLiveFolder.CONTENT_URI);
		intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_NAME, "Open Search");
		intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_DISPLAY_MODE, LiveFolders.DISPLAY_MODE_LIST);
		intent.putExtra(LiveFolders.EXTRA_LIVE_FOLDER_BASE_INTENT, new Intent(Intent.ACTION_VIEW, Provider.CONTENT_URI));
		return intent;
	}
}
